package com.ysd.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import com.ysd.entity.Company;
import com.ysd.util.DBManager;

public class CompanyDaoImpl {
	public Company getCompany() {
		Connection conn = DBManager.getConnection();
		Statement st = null;
		ResultSet rs = null;
		Company company = null;
		try {
			st = conn.createStatement();
			rs = st.executeQuery("select * from company");
			while(rs.next()) {
				String name = rs.getString("name");
				String webSite = rs.getString("webSite");
				String introduction = rs.getString("introduction");
				String phone = rs.getString("phone");
				String email = rs.getString("email");
				String address = rs.getString("address");
				String culture  = rs.getString("culture");
				String logo = rs.getString("logo");
				company = new Company(name, webSite, introduction, phone, email, address, culture, logo);				
			}
			return company;
		} catch (SQLException e) {			
			e.printStackTrace();
			return null;			
		}finally {
			DBManager.closeAll(conn, st, rs);
		}
	}
}
